<template>
    <div class="common-box" v-if="boxIsShow">
        <div class="common-content-box">
            <div class="common-content-top-box">
                本月：{{topData.thismonth}}元 上月：{{topData.lastmonth}}元 合计：{{topData.total}}元
            </div>
            <div class="common-content-bottom-box">
                <div class="table_search_box">
                    <el-form :inline="true" :model="searchForm" class="demo-form-inline">
                          <el-form-item label="充值用户">
                            <el-input v-model="searchForm.useName" placeholder="请输入" size="small"></el-input>
                          </el-form-item>
                          <el-form-item label="充值时间">
                            <el-date-picker
                                v-model="searchForm.chargeDate"
                                type="date"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd"
                                style="width: 100%;"
                                size="small">
                            </el-date-picker>
                          </el-form-item>
                        <el-form-item>
                          <el-button type="primary" @click="search" size="small">查询</el-button>
                          <el-button type="primary" @click="initsearch" size="small" plain>清空</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="table_box">
                    <el-table
                        :data="tableData"
                        stripe
                        style="width: 100%">
                        <el-table-column
                        prop="id"
                        label="充值ID"
                        width="80"
                        align="center">
                        </el-table-column>
                        <el-table-column
                        prop="uname"
                        label="会员名称"
                        width="180"
                        align="center">
                        </el-table-column>
                        <el-table-column
                        prop="money"
                        label="充值金额"
                        align="center"
                        width="180">
                        </el-table-column>
                        <el-table-column
                        prop="point"
                        label="充值算力"
                        align="center"
                        width="200">
                        </el-table-column>
                        <el-table-column
                        label="充值时间"
                        prop="createTime"
                        align="center">
                        </el-table-column>
                    </el-table>
                    <pagination
                    :total="total"
                    :limit="pageSize"
                    :page="pageNumber"
                    :pageSize="pageSize"
                    @pageChange="pageChange"
                    ></pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import Pagination from "@/components/pagination.vue";
export default {
    components: {
        Pagination
    },
  data() {
    return {
        boxIsShow:false,
        searchForm:{
            chargeDate:"",
            useName:""
        },
        total: 0,
        pageSize: 30,
        pageNumber: 1,
        tableData:[],
        topData:null
    };
  },
  created() {
    
  },
  mounted(){
  },
  methods: {
    __init() {
        this.getTopData();
        this.getDataList();
    },
    getTopData(){
        var url="manager/getChargeMoneyTotal";
        var params={}
        this.$post(url, params).then((res) => {
            console.log(res)
            if (res.code === 200) {
                this.topData=res.data;
            } else {
            this.$message.error(res.msg)
            }
        });
    },
    getDataList(){
      var url="manager/getChargeOrderListByPage";
      var params={
        ...this.searchForm,
        pageSize: this.pageSize,
        pageNum: this.pageNumber
      }
      this.$post(url, params).then((res) => {
        console.log(res)
        if (res.code === 200) {
            this.tableData=res.data.list;
            this.total=res.data.total;
        } else {
          this.$message.error(res.msg)
        }
      });
    },
    pageChange(e) {
      this.pageNumber = e.page;
      this.getDataList();
    },
    search(){
      this.pageNumber=1;
      this.getDataList();
    },
    initsearch(){
        this.searchForm={
            chargeDate:"",
            useName:""
        }
        this.pageNumber=1;
        this.getDataList();
    }
  }
}
</script>
<style scoped lang="scss">
  .common-box{
    background-color: #f9f9fb;
    height: 100%;
    position: relative;
  }
  .common-content-box{
    height: 95%;
    margin-top: 2%;
    width: 96%;
    display: inline-block;
  }
  .common-content-top-box{
    width: 98%;
    background-color: #fff;
    min-height: 60px;
    line-height:60px;
    box-shadow: 1px 1px 6px 2px rgba(0,0,0,0.1);
    border-radius: 5px;
    text-align: left;
    padding-left:2%
  }
  .form_box{
    margin-left: 20px;
    margin-top: 25px;
    width: 40%;
    display: inline-block;
  }
  .common-content-bottom-box{
    width: 100%;
    background-color: #fff;
    min-height: 200px;
    box-shadow: 1px 1px 6px 2px rgba(0,0,0,0.1);
    border-radius: 5px;
    margin-top: 30px;
    padding: 20px 0;
  }
  .table_search_box{
    text-align: left;
    width: 96%;
    margin-left: 2%;
    display: inline-block;
    margin-top: 20px;
  }
  .table_box{
    width: 96%;
    margin-left: 2%;
    height: calc(100% - 255px);
  }
</style>